package com.mybatis.dto;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class MyModelDto {
    private Field field;
    private Method getMethod;
    private Method setMethod;

    //获取当前属性上的注解
    public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
        T t = this.field.getAnnotation(annotationClass);
        if (t == null && this.getMethod != null) {
            t = this.getMethod.getAnnotation(annotationClass);
        }

        if (t == null && this.setMethod != null) {
            t = this.setMethod.getAnnotation(annotationClass);
        }

        return t;
    }

    public Field getField() {
        return field;
    }

    public void setField(Field field) {
        this.field = field;
    }

    public Method getGetMethod() {
        return getMethod;
    }

    public void setGetMethod(Method getMethod) {
        this.getMethod = getMethod;
    }

    public Method getSetMethod() {
        return setMethod;
    }

    public void setSetMethod(Method setMethod) {
        this.setMethod = setMethod;
    }
}
